interface KHTMLElement {
    /**
     * 查找父元素
     * @returns 父元素数组
     */
    parents(): KHTMLElement;
    /**
     * 查找符合条件的父元素
     * @param selectors 选择器
     * @returns 父元素数组
     */
    parents(selectors: string): KHTMLElement;
}
{
    Object.defineProperty(KHTMLElement.prototype, 'parents', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: U.F.overloading('DOM-parents',
            {
                types: [Etype.string],
                fn: function (this: KHTMLElement, selectors: string) {
                    const parents = new KHTMLElement();
                    this.elements.forEach(ele => {
                        let ele_parent = ele.parentElement!;
                        for (; U.is(Etype.HTMLElement, ele_parent) && ele_parent !== document.body; ele_parent = ele_parent.parentElement!) {
                            if (ele_parent.matches(selectors)) {
                                parents.push(ele_parent);
                            }
                        }
                    });
                    return parents;
                }
            },
            {
                types: [U.F.argType.optionalAny],
                fn: function (this: KHTMLElement) {
                    const parents = new KHTMLElement();
                    this.elements.forEach(ele => {
                        let ele_parent = ele.parentElement!;
                        for (; U.is(Etype.HTMLElement, ele_parent) && ele_parent !== document.body; ele_parent = ele_parent.parentElement!) {
                            parents.push(ele_parent);
                        }
                    });
                    return parents;
                }
            },
        )
    });
}
